package com.sx.pipeline.adapter

import android.view.View
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.noober.background.view.BLTextView
import com.sx.pipeline.R
import com.sx.pipeline.repos.http.res.ExamineOperatorVo
import com.sx.pipeline.repos.http.res.ExamineRecordVo

class ExamineRecordAdapter : BaseQuickAdapter<ExamineRecordVo, BaseViewHolder>
    (R.layout.item_examine_record, mutableListOf()) {
    override fun convert(holder: BaseViewHolder, item: ExamineRecordVo) {
        val tabStatus = mutableListOf<String>("待审核", "审核通过", "审核驳回","已取消")
        holder.setText(R.id.tv_time, item.createTime.orEmpty())
        holder.setText(R.id.tv_status, tabStatus[item.status ?: 0])
        holder.setText(R.id.tv_remark, "驳回原因：${item.remark.orEmpty()}")
        holder.getView<BLTextView>(R.id.tv_again).visibility=if(item.status==0) View.VISIBLE else View.GONE
        holder.getView<BLTextView>(R.id.tv_cancel).visibility=if(item.status==0) View.VISIBLE else View.GONE
        holder.getView<TextView>(R.id.tv_remark).visibility=if(item.status==3) View.VISIBLE else View.GONE
        holder.getView<TextView>(R.id.tv_name).text=item.unitName.orEmpty()
        when(item.identity) {
            "0" -> {
                holder.setText(R.id.tv_identity, "申请身份:运营单位")
            }
            "1" -> {
                holder.setText(R.id.tv_identity, "申请身份:施工单位")
            }
            "2" -> {
                holder.setText(R.id.tv_identity, "申请身份:供应商")
            }
        }
        holder.getView<BLTextView>(R.id.tv_again).setOnClickListener{
            getOnItemClickListener()?.onItemClick(this@ExamineRecordAdapter,it,holder.layoutPosition)
        }
        holder.getView<BLTextView>(R.id.tv_cancel).setOnClickListener{
            getOnItemClickListener()?.onItemClick(this@ExamineRecordAdapter,it,holder.layoutPosition)
        }
    }
}